import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-super-coupon',
  templateUrl: './super-coupon.component.html',
  styleUrls: ['./super-coupon.component.css']
})
export class SuperCouponComponent implements OnInit {
  currentPage:number=1;
  numPages:number=0;
  curPageNum:number=1;
  query : string = "";
  constructor(private router : Router,private route : ActivatedRoute) { }

  ngOnInit() {
    this
      .route
      .params
      .subscribe(x => {
        this.route.queryParams.subscribe(p=>{
          this.query = x.query;
          this.currentPage = p.pn||1;
          this.curPageNum=parseInt(p.pn);
        });
      });
  }
  pageChanged(ev){
    if(this.query){
      this.router.navigate( ['super',this.query],{queryParams:{pn:ev.page}});
    }else{
      this.router.navigate( ['super'],{queryParams:{pn:ev.page}});
    }
  }
}
